<?php

namespace app\index\controller\source;

use ShidianUtil\Thinkphp\Response\ApiResponse;
use ShidianUtil\Utils\CheckUtil;
use app\index\model\UM as UM;
use app\index\service\SourceCollectedService;
use think\APP;
use think\Request as Request;

/**
 * SourceCollected 控制器
 * Class SourceCollected
 * @package app\index\controller\source;
 * @link https://www.kancloud.cn/manual/thinkphp6_0/1037509
 * @see \app\index\validate\source\SourceCollected
 */
class SourceCollected
{
    // 请求参数
    private Request $request;

    // service
    private SourceCollectedService $service;

    public function __construct(Request $request, SourceCollectedService $sourceCollectedService)
    {
        $this->request = $request;
        $this->service = $sourceCollectedService;
    }

    /**
     * 列表
     * @param UM|null $user
     * @return ApiResponse
     * @url /source/source_collected/index
     */
    public function index(UM $user): ApiResponse
    {
        $request     = $this->request;

        return ApiResponse::success($this->service->index($user, $request->param()));
    }

}
